<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增【请填写功能名称】')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-vgroup-add">

            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">用户组：</label>
                    <div class="col-sm-8">
                        <input name="vgroupname"  class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">VIP时长：</label>
                    <div class="col-sm-8">
                        <input name="vipdays"  class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">阅读折扣：</label>
                    <div class="col-sm-8">
                        <input name="discount"  class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">下载折扣：</label>
                    <div class="col-sm-8">
                        <input name="discount2"  class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">日下载上限：</label>
                    <div class="col-sm-8">
                        <input name="downcount"  class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">总下载上限：</label>
                    <div class="col-sm-8">
                        <input name="downcount2"  class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">价格上限：</label>
                    <div class="col-sm-8">
                        <input name="docmoney"  class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">开通原价：</label>
                    <div class="col-sm-8">
                        <input name="cash"  class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">优惠价格：</label>
                    <div class="col-sm-8">
                        <input name="cash2"  class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">推荐：</label>
                    <div class="col-sm-8">
                        <label class="toggle-switch switch-solid">
                            <input  id="suggest" type="checkbox"  >
                            <span></span>
                        </label>
                    </div>
                </div>
            </div>


            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">启用：</label>
                    <div class="col-sm-8">
                        <label class="toggle-switch switch-solid">
                            <input  id="state" type="checkbox"  >
                            <span></span>
                        </label>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "system/vgroup"
        $("#form-vgroup-add").validate({
            rules:{
                vgroupname: "required",
                vipdays: {
                    digits:true
                },
                discount2: "required",
                discount: "required",
                docmoney: "required",
                cash: "required",
                cash2: "required",
                downcount:{
                    number:true
                },
                downcount2:{
                    number:true
                }

            },
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                var data = $("#form-vgroup-add").serializeArray();
                var state = $("input[id='state']").is(':checked') == true ? 1 : 0;
                var suggest = $("input[id='suggest']").is(':checked') == true ? 1 : 0;
                data.push({"name": "state", "value": state});
                data.push({"name": "suggest", "value": suggest});
                $.operate.save(prefix + "/add", data);
            }
        }


    </script>
</body>
</html>